package com.hmall.order.web;

import com.hmall.order.pojo.Order;
import com.hmall.order.pojo.RequestParams;
import com.hmall.order.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author www
 * @Description 订单Controller
 * @Date 2023/4/11 11:28
 * @Version 1.0
 */
@RestController
@RequestMapping("order")
public class OrderController {

   /**
    * 注入IOrderService
    */
   @Autowired
   private IOrderService orderService;

   @GetMapping("{id}")
   public Order queryOrderById(@PathVariable("id") Long orderId) {
      return orderService.getById(orderId);
   }

   /**
    * 创建订单业务
    * @param params 前端数据
    * @return 订单id
    */
   @PostMapping
   public Long createOrder(@RequestBody RequestParams params){
      return orderService.createOrder(params);
   }
}
